package edu.uwm.cs552;

import java.awt.Graphics;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import edu.uwm.cs552.util.FormatException;

public interface TopographyBoard {

	/**
	 * Draw the game board into the given graphics context.
	 * @param g graphics context, must not be null
	 * @param scale width of coordinate
	 * @param drawMesh whether to draw the outline of all coordinate
	 */
	public abstract void draw(Graphics g);

	/**
	 * Get the height of the board (the height of the background image)
	 * given the current scale.
	 * @param scale scale to use
	 * @return height of board.
	 */
	public abstract int getHeight();

	/**
	 * Get the width of the board (the width of the background image)
	 * given the current scale.
	 * @param scale scale to use
	 * @return width of board
	 */
	public abstract int getWidth();

	/**
	 * Write a coord board out using the form:
	 * <pre>
	 * <i>URL (or empty, if no background image)</i>
	 * <i>width</i>
	 * <i>height</i>
	 * <i>[The following section repeated indefinitely]</i>
	 * <i>terrain</i>
	 * <i>hexcoordinate<sb>1</db></i>
	 * <i>hexcoordinate<sb>2</db></i>
	 * ...
	 * <i>hexcoordinate<sb>n</db></i>
	 * </pre>
	 * @param pw output to use, must not be null
	 */
	public abstract void write(PrintWriter pw);

	/**
	 * Read in a coord board using the format given in {@link #write(PrintWriter)}.
	 * Throw an appropriate exception given a problem.
	 * @param br buffered reader to use, must not be null
	 * @throws IOException if there is an error reading the file, or if the URL is bad, or the SVG in it
	 * @throws FormatException an error reading a hex coordinate or terrain
	 * @throws NumberFormatException an error reading the width or height
	 */
	public abstract void read(BufferedReader br) throws IOException,
			FormatException, NumberFormatException;

}